<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Activity';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin'], function ($api) {

    $allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;

    // $api->resource('seckill', "SeckillController", ['only' => $allMethod]);
    // $api->resource('lottery', "LotteryController", ['only' => $allMethod]);
    // $api->resource('egg-lottery', "EggLotteryController", ['only' => $allMethod]);
    // $api->get('/lottery/{uuid}/users', ['uses'=> "LotteryController@userIndex"]);

    // $api->resource('activities', "ActivityController", ['only' => $allMethod]);
    // $api->resource('activities.skus', "ActivitySkuController", ['only' => $allMethod]);

    // 共用
    $api->get('/status-total/activity/{type}', ['uses'=> "ActivityController@statusTotal"]);

    // 一番赏
    $api->resource('yi-fan-shangs', "YiFanShang\ActivityController", ['only' => $allMethod]);
    $api->get('/yi-fan-shang/skus', ['uses'=> "YiFanShang\SkuController@index"]);
    $api->PUT('/yi-fan-shang/skus/{uuid}', ['uses'=> "YiFanShang\SkuController@update"]);
    $api->get('/yifanshang/{uuid}/rooms', ['uses'=> "YiFanShang\RoomController@index"]);
    // 编辑概率
    $api->get('/yifanshang/odds', ['uses'=> "YiFanShang\OddsController@index"]);
    $api->put('/yifanshang/odds', ['uses'=> "YiFanShang\OddsController@update"]);
    // 模拟测试
    $api->POST('/yfs/rooms/{uuid}/run-test', ['uses'=> "YiFanShang\ActivityController@runTest"]);

    // 福袋
    $api->resource('fudais', "Fudai\ActivityController", ['only' => $allMethod]);
    $api->PUT('/fudai/skus/{uuid}', ['uses'=> "Fudai\SkuController@update"]);
    $api->get('/fudais/{uuid}/skus', ['uses'=> "Fudai\SkuController@index"]);
    $api->POST('/fudais/{uuid}/skus', ['uses'=> "Fudai\SkuController@store"]);
    $api->delete('/fudai/skus/{uuid}', ['uses'=> "Fudai\SkuController@destroy"]);
    $api->PUT('/fudais/{uuid}/sku-level', ['uses'=> "Fudai\ActivityController@updateSkuLevel"]);
    $api->POST('/fudais/{uuid}/test-lottery', ['uses'=> "Fudai\ActivityController@testLottery"]);
    // 复制活动
    $api->post('/fudais/{uuid}/copy', ['uses'=> "Fudai\ActivityController@copy"]);


    // 抽奖
    $api->resource('lotteries', "Lottery\ActivityController", ['only' => $allMethod]);
    $api->resource('/lottery/skus', "Lottery\SkuController", ['only' => $allMethod]);
    $api->resource('/lotteries/{lotteryUuid}/users', "Lottery\UserController", ['only' => $allMethod]);

    // 秒杀
    $api->resource('seckills', "Seckill\ActivityController", ['only' => $allMethod]);

    // 扭蛋机
    $api->resource('egg-lotteries', "EggLottery\ActivityController", ['only' => $allMethod]);
    $api->resource('/egg-lottery/skus', "EggLottery\SkuController", ['only' => $allMethod]);

    // 抽赏
    $api->resource('choushangs', "Choushang\ActivityController", ['only' => $allMethod]);
    $api->get('choushangs_patch/{type}', "Choushang\ActivityController@doPatch");
    $api->get('choushangs_getCnt', "Choushang\ActivityController@getCnt");
    $api->get('choushangs_getList', "Choushang\ActivityController@getList");
    $api->resource('/choushang/skus', "Choushang\SkuController", ['only' => $allMethod]);
    $api->resource('/choushang/last_skus', "Choushang\LastSkuController", ['only' => $allMethod]);
    $api->post('/choushangs_off_stock_all', ['uses'=> "Choushang\ActivityController@off_stock_all"]);
    $api->post('/choushangs_copy_more/{uuid}', ['uses'=> "Choushang\ActivityController@copy_more"]);
    $api->post('/choushangs_copy_main/{uuid}', ['uses'=> "Choushang\ActivityController@copy_main"]);
    $api->post('/choushangs_copy_one/{uuid}', ['uses'=> "Choushang\ActivityController@copy_one"]);

    // 擂台
    $api->resource('leitais', "Leitai\ActivityController", ['only' => $allMethod]);
    $api->get('leitais_patch/{type}', "Leitai\ActivityController@doPatch");
    $api->get('leitais_getCnt', "Leitai\ActivityController@getCnt");
    $api->get('leitais_getList', "Leitai\ActivityController@getList");
    $api->resource('/leitai/skus', "Leitai\SkuController", ['only' => $allMethod]);
    $api->resource('/leitai/last_skus', "Leitai\LastSkuController", ['only' => $allMethod]);
    $api->post('/leitais_off_stock_all', ['uses'=> "Leitai\ActivityController@off_stock_all"]);
    $api->post('/leitais_copy_more/{uuid}', ['uses'=> "Leitai\ActivityController@copy_more"]);
    $api->post('/leitais_copy_one/{uuid}', ['uses'=> "Leitai\ActivityController@copy_one"]);

    // 大转盘
    $api->resource('rotate-lotteries', "RotateLottery\ActivityController", ['only' => $allMethod]);
    $api->resource('/rotate-lottery/skus', "RotateLottery\SkuController", ['only' => $allMethod]);

    // 集卡
    $api->resource('jikas', "Jika\ActivityController", ['only' => $allMethod]);
    $api->resource('/jika/tasks', "Jika\TaskController", ['only' => $allMethod]);
    $api->resource('/jika/skus', "Jika\SkuController", ['only' => $allMethod]);
    $api->get('/jika/swap-records', ['uses'=> "Jika\SwapRecordController@index"]);
    // $api->resource('/jika/skus', "Jika\SkuController", ['only' => $allMethod]);
    // $api->resource('/jika/cards', "Jika\CardController", ['only' => $allMethod]);


    // 助力活动
    $api->resource('zhili/activities', "Zhuli\ActivityController", ['only' => $allMethod]);
    $api->resource('/zhuli/skus', "Zhuli\SkuController", ['only' => $allMethod]);
});


// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client'], function ($api) {

    $allMethod = ['index', 'show', 'store', 'update', 'destroy'];

    // 一番赏
    $api->get('/yifanshangs', ['uses'=> "YiFanShang\ActivityController@index"]);
    $api->get('/yifanshangs/{uuid}', ['uses'=> "YiFanShang\ActivityController@show"]);
    $api->post('/yifanshang/preview-orders', ['uses'=> "YiFanShang\OrderController@preview"]);
    $api->post('/yifanshang/orders', ['uses'=> "YiFanShang\OrderController@store"]);
    $api->get('/yifanshang/{uuid}/rooms', ['uses'=> "YiFanShang\RoomController@index"]);
    $api->get('/yifanshang/{uuid}/records', ['uses'=> "YiFanShang\RecordController@index"]);

    $api->get('/yifanshang/{uuid}/record-total', ['uses'=> "YiFanShang\RecordController@total"]);

    // 福袋
    $api->get('/fudais', ['uses'=> "Fudai\ActivityController@index"]);
    $api->get('/home/fudais', ['uses'=> "Fudai\ActivityController@homeIndex"]);
    $api->get('/fudais/{uuid}', ['uses'=> "Fudai\ActivityController@show"]);
    $api->POST('/fudai/change', ['uses'=> "Fudai\ActivityController@change"]);
    $api->POST('/fudai/try', ['uses'=> "Fudai\OrderController@try"]);
    // 购买福袋
    $api->POST('/fudai/order/preview', ['uses'=> "Fudai\OrderController@preview"]);
    $api->POST('/fudai/order/confirm', ['uses'=> "Fudai\OrderController@store"]);
    // 使用道具卡
    $api->post('/fudai/use-card', ['uses'=> "Fudai\CardController@use"]);
    // 榜单 (旧版，将于 5.0 版中删除）
    $api->get('/fudais/{uuid}/rank', ['uses'=> "Fudai\RankController@index"]);
    // 开盒记录（新版）
    $api->get('/fudais/{uuid}/records', ['uses'=> "Fudai\RecordController@index"]);
    // 首页配置
    $api->get('/fudai/home/config', ['uses'=> "Fudai\ActivityController@homeConfig"]);


    // 抽奖
    $api->get('/lotteries', ['uses'=> "Lottery\ActivityController@index"]);
    $api->get('/lotteries/{uuid}', ['uses'=> "Lottery\ActivityController@show"]);
    $api->post('/lottery/order/preview', ['uses'=> "Lottery\OrderController@preview"]);
    $api->post('/lottery/order/confirm', ['uses'=> "Lottery\OrderController@store"]);
    $api->get('/lottery/order/storeJob', ['uses'=> "Lottery\OrderController@storeJob"]);
    $api->get('/lottery/order/getJobUser', ['uses'=> "Lottery\OrderController@getJobUser"]);
    $api->get('/lotteries/{uuid}/users', ['uses'=> "Lottery\UserController@index"]);
    $api->get('/lotteries/{uuid}/lucky-users', ['uses'=> "Lottery\UserController@luckyUserIndex"]);
    $api->get('lotteries/{uuid}/my-tickets', ['uses'=> "Lottery\TicketController@myIndex"]);
    $api->get('lotteries/{uuid}/my-invitees', ['uses'=> "Lottery\InviteController@myInviteeIndex"]);
    $api->get('lotteries/{uuid}/invite-info', ['uses'=> "Lottery\InviteController@inviteInfo"]);
    $api->post('lotteries/{uuid}/accept-invite', ['uses'=> "Lottery\InviteController@acceptInvite"]);

    // 秒杀
    $api->get('/seckills', ['uses'=> "Seckill\ActivityController@index"]);
    $api->get('/seckills/{uuid}', ['uses'=> "Seckill\ActivityController@show"]);
    $api->post('/seckills/{uuid}/check-user-group', ['uses'=> "Seckill\ActivityController@checkUserGroup"]);

    // 抽奖
    $api->get('/egg-lotteries', ['uses'=> "EggLottery\ActivityController@index"]);
    $api->get('/egg-lotteries/{uuid}', ['uses'=> "EggLottery\ActivityController@show"]);
    $api->post('/egg-lottery/order/preview', ['uses'=> "EggLottery\OrderController@preview"]);
    $api->post('/egg-lottery/order/confirm', ['uses'=> "EggLottery\OrderController@confirm"]);
    $api->post('/egg-lottery/order/try', ['uses'=> "EggLottery\OrderController@try"]);

    // 抽赏
    $api->get('/choushangs', ['uses'=> "Choushang\ActivityController@index"]);
    $api->get('/choushangs_group', "Choushang\ActivityController@getGroupList");
    $api->get('/choushang_bang/{id}', "Choushang\ActivityController@choushangsBang");
    $api->get('/choushangs/{uuid}', ['uses'=> "Choushang\ActivityController@show"]);
    $api->get('/choushang_log/{id}', ['uses'=> "Choushang\ActivityController@choushangLog"]);
    $api->get('/choushang_group', ['uses'=> "Choushang\ActivityController@choushangGroup"]);
    $api->post('/choushang/order/preview', ['uses'=> "Choushang\OrderController@preview"]);
    $api->post('/choushangs/order/confirm', ['uses'=> "Choushang\OrderController@confirm"]);
    $api->post('/choushangs/order/try', ['uses'=> "Choushang\OrderController@try"]);

    // 擂台
    
    $api->get('/getdingshirenwuleitai', "Leitai\ActivityController@getdingshirenwuleitai");
    $api->get('/leitais_jiqiren/{uuid}', "Leitai\ActivityController@getRequestOpenBox");
    $api->get('/leitais', ['uses'=> "Leitai\ActivityController@index"]);
    $api->get('/leitais_group', "Leitai\ActivityController@getGroupList");
    $api->get('/leitais_sku/{activity_id}', "Leitai\ActivityController@getLeitaiSku");
    $api->get('/leitais/{uuid}', ['uses'=> "Leitai\ActivityController@show"]);
    $api->get('/leitai_kongche', ['uses'=> "Leitai\ActivityController@getKongCheNums"]);
    $api->get('/leitai_log/{id}', ['uses'=> "Leitai\ActivityController@leitaiLog"]);
    $api->post('/leitai/order/preview', ['uses'=> "Leitai\OrderController@preview"]);
    $api->post('/leitais/order/confirm', ['uses'=> "Leitai\OrderController@confirm"]);
    $api->post('/leitais/order/try', ['uses'=> "Leitai\OrderController@try"]);
    $api->get('/leitai_bang/{id}', "Leitai\ActivityController@leitaisBang");
    $api->get('/leitaiCron/cronBeginJob', "Leitai\OrderController@job");
    $api->get('/leitaiCron/leitaiOpenChk', "Leitai\OrderController@leitaiOpenChk");
    $api->post('/leitaiCron/cronBegin', "Leitai\OrderController@cronBeginChk");
    $api->get('/leitaiCron/leitaiDataSum', "Leitai\OrderController@leitaiDataSum");
    $api->get('/leitaiChk/openBox', "Leitai\OrderController@openBox");


    // 大转盘
    $api->get('/rotate-lotteries', ['uses'=> "RotateLottery\ActivityController@index"]);
    $api->get('/rotate-lotteries/{uuid}', ['uses'=> "RotateLottery\ActivityController@show"]);
    // $api->post('/rotate-lottery/order/preview', ['uses'=> "RotateLottery\OrderController@preview"]);
    // $api->post('/rotate-lottery/order/confirm', ['uses'=> "RotateLottery\OrderController@confirm"]);
    // $api->post('/rotate-lottery/order/try', ['uses'=> "RotateLottery\OrderController@try"]);
    $api->post('/rotate-lotteries/{uuid}/run', ['uses'=> "RotateLottery\OrderController@run"]);

    // 集卡
    $api->get('/jikas', ['uses'=> "Jika\ActivityController@index"]);
    $api->get('/jikas/{uuid}', ['uses'=> "Jika\ActivityController@show"]);
    // 兑换礼品
    $api->post('/jika/swap/confirm', ['uses'=> "Jika\SkuController@swap"]);


    // 助力活动 
    $api->get('/zhuli/activities', ['uses'=> "Zhuli\ActivityController@index"]);
    $api->get('/zhuli/activities/{uuid}', ['uses'=> "Zhuli\ActivityController@show"]);
    $api->post('/zhuli/launch-records', ['uses'=> "Zhuli\LaunchRecordController@store"]);
    $api->post('/zhuli/support-records', ['uses'=> "Zhuli\LaunchRecordController@support"]);
    $api->get('/zhuli/launch-records/{uuid}', ['uses'=> "Zhuli\LaunchRecordController@show"]);
    // 我发起的记录
    $api->get('/zhuli/my-launch-records', ['uses'=> "Zhuli\LaunchRecordController@myIndex"]);


    // 兑换活动参与次数
    $api->post('/activity/buy-ticket/preview', ['uses'=> "TicketController@buyPreview"]);
    $api->post('/activity/buy-ticket', ['uses'=> "TicketController@buy"]);
    $api->get('/activity/ticket-records', ['uses'=> "TicketRecordController@index"]);
    $api->get('/activity/ticket-total', ['uses'=> "TicketController@total"]);
    $api->get('/activity/invite-records', ['uses'=> "InviteRecordController@index"]);

    $api->get('/activity/ticket-total2', ['uses'=> "TicketController@total2"]);
    $api->get('/activity/invite-records2', ['uses'=> "InviteRecordController@index2"]);


    // 流水记录
    $api->get('/user/amount_day', ['uses'=> "ActivityController@getAmountSum"]);

    // 数据清理
    $api->get('/data/clear', "Leitai\OrderController@clear");

});
